mod_rewrite and location

mod_rewrite and location

am 29.03.2010 11:23:24 von Henrik Gemal

I use mod_rewrite and in the root of the website I have this in the
..htaccess file:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]


My index.php is simple:


My URLs are something like this:
http://localhost/program1/info
http://localhost/program2/info

Now I want to restrict the access to /program2 to certain IP.

I've tried:

Order deny,allow
Deny from all


Order deny,allow
Allow from all


Order deny,allow
Allow from 127.0.0.1


But it doesn't work

If I try to load http://localhost/program2 I get:
"You don't have permission to access /index.php on this server."

So it had something to do with mod_rewrite

Help

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: mod_rewrite and location

am 29.03.2010 11:42:20 von Igor Cicimov

--001636c925e44f20000482ed548a
Content-Type: text/plain; charset=ISO-8859-1

Your RewriteRule is wrong redirects everything to index.php in the root
directory where you dont have access

On Mar 29, 2010 8:24 PM, "Henrik Gemal" wrote:

I use mod_rewrite and in the root of the website I have this in the
..htaccess file:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]


My index.php is simple:


My URLs are something like this:
http://localhost/program1/info
http://localhost/program2/info

Now I want to restrict the access to /program2 to certain IP.

I've tried:

Order deny,allow
Deny from all


Order deny,allow
Allow from all


Order deny,allow
Allow from 127.0.0.1


But it doesn't work

If I try to load http://localhost/program2 I get:
"You don't have permission to access /index.php on this server."

So it had something to do with mod_rewrite

Help

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

--001636c925e44f20000482ed548a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Your RewriteRule is wrong redirects everything to index.php in the root =
directory where you dont have access


On Mar 29, 2010 8:24 PM, "Henrik Gemal&qu=
ot; <> wrote:

=
=A0I use mod_rewrite and in the root of the website I have this in the .hta=
ccess file:




<IfModule mod_rewrite.c>

=A0 =A0RewriteEngine On

=A0 =A0RewriteCond %{REQUEST_FILENAME} !-d

=A0 =A0RewriteCond %{REQUEST_FILENAME} !-f

=A0 =A0RewriteRule ^(.*)$ index.php?url=3D$1 [qsappend,last]

</IfModule>



My index.php is simple:

<?php echo "hello"; ?>



My URLs are something like this:

http://localho=
st/program1/info


http://localho=
st/program2/info




Now I want to restrict the access to /program2 to certain IP.



I've tried:

<Location />

=A0 Order deny,allow

=A0 Deny from all

</Location>

<Location /program1>

=A0 Order deny,allow

=A0 Allow from all

</Location>

<Location /program2>

=A0 Order deny,allow

=A0 Allow from 127.0.0.1

</Location>



But it doesn't work



If I try to load ht=
tp://localhost/program2
I get:

"You don't have permission to access /index.php on this server.&qu=
ot;



So it had something to do with mod_rewrite



Help



------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g" target=3D"_blank">users-unsubscribe@httpd.apache.org

=A0" =A0 from the digest: httpd.apache.org" target=3D"_blank">users-digest-unsubscribe@httpd.apache.o=
rg


For additional commands, e-mail: org" target=3D"_blank">users-help@httpd.apache.org





--001636c925e44f20000482ed548a--

Re: mod_rewrite and location

am 29.03.2010 11:57:50 von Henrik Gemal

--------------050305090405010909050302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

The problem is that if I do:


Order deny,allow
Deny from all


Order deny,allow
Allow from all


Order deny,allow
Deny from all
Allow from 127.0.0.1


then calling http://localhost/index.php/program2 would access program2
when he shouldn't

On 29-03-2010 11:42, Igor Cicimov wrote:
>
> Your RewriteRule is wrong redirects everything to index.php in the
> root directory where you dont have access
>
>> On Mar 29, 2010 8:24 PM, "Henrik Gemal" >> > wrote:
>>
>> I use mod_rewrite and in the root of the website I have this in the
>> .htaccess file:
>>
>>
>> RewriteEngine On
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]
>>

>>
>> My index.php is simple:
>>
>>
>> My URLs are something like this:
>> http://localhost/program1/info
>> http://localhost/program2/info
>>
>> Now I want to restrict the access to /program2 to certain IP.
>>
>> I've tried:
>>
>> Order deny,allow
>> Deny from all
>>

>>
>> Order deny,allow
>> Allow from all
>>

>>
>> Order deny,allow
>> Allow from 127.0.0.1
>>

>>
>> But it doesn't work
>>
>> If I try to load http://localhost/program2 I get:
>> "You don't have permission to access /index.php on this server."
>>
>> So it had something to do with mod_rewrite
>>
>> Help
>>
>> ------------------------------------------------------------ ---------
>> The official User-To-User support forum of the Apache HTTP Server
>> Project.
>> See for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>
>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>>
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>

--------------050305090405010909050302
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit




http-equiv="Content-Type">


The problem is that if I do:



    <Location />

        Order deny,allow

        Deny from all

    </Location>

    <Location /index.php>

        Order deny,allow

        Allow from all

    </Location>

    <Location /program2>

        Order deny,allow

        Deny from all

        Allow from 127.0.0.1

    </Location>



then calling would access
program2 when he shouldn't



On 29-03-2010 11:42, Igor Cicimov wrote:
cite="mid:f89deef01003290242q12cfe70fl1287438e6e3b9e58@mail. gmail.com"
type="cite">

Your RewriteRule is wrong redirects everything to index.php in
the root directory where you dont have access


On Mar 29, 2010 8:24 PM, "Henrik Gemal"
<>
wrote:



 I use mod_rewrite and in the root of the website I have this in
the .htaccess file:



<IfModule mod_rewrite.c>

   RewriteEngine On

   RewriteCond %{REQUEST_FILENAME} !-d

   RewriteCond %{REQUEST_FILENAME} !-f

   RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]

</IfModule>



My index.php is simple:

<?php echo "hello"; ?>



My URLs are something like this:

target="_blank">http://localhost/program1/info

target="_blank">http://localhost/program2/info



Now I want to restrict the access to /program2 to certain IP.



I've tried:

<Location />

  Order deny,allow

  Deny from all

</Location>

<Location /program1>

  Order deny,allow

  Allow from all

</Location>

<Location /program2>

  Order deny,allow

  Allow from 127.0.0.1

</Location>



But it doesn't work



If I try to load href="http://localhost/program2" target="_blank">http://localhost/program2
I get:

"You don't have permission to access /index.php on this server."



So it had something to do with mod_rewrite



Help



------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP
Server Project.

See <URL: href="http://httpd.apache.org/userslist.html" target="_blank">http://httpd.apache.org/userslist.html>
for more info.

To unsubscribe, e-mail: href="mailto:users-unsubscribe@httpd.apache.org"
target="_blank">users-unsubscribe@httpd.apache.org


 "   from the digest: href="mailto:users-digest-unsubscribe@httpd.apache.org"
target="_blank">users-digest-unsubscribe@httpd.apache.org


For additional commands, e-mail: href="mailto:users-help@httpd.apache.org" target="_blank">users-help@httpd.apache.org








--------------050305090405010909050302--

Re: mod_rewrite and location

am 29.03.2010 12:54:00 von ef-lists

10/03/29 Henrik Gemal
> I use mod_rewrite and in the root of the website I have this
> in the .htaccess file:

Hi,

mixing Location with .htaccess sounds wrong to me, as Location
should be processed before URL-to-file mapping, but .htaccess can
only be accessed after URL-to-file mapping.

Be sure to read about the rewrite base directive here:
http://httpd.apache.org/docs/2.2/en/mod/mod_rewrite.html

and even if you don't understand all of the details, you should
read this:
http://httpd.apache.org/docs/2.2/en/rewrite/rewrite_tech.htm l

Then, define a RewriteLog (see mod_rewrite documentation) and set
a RewriteLogLevel of 3 or 4 and watch carefully what's going on
inside of mod_rewrite.

This really puts you into the position of understanding the
details instead of just providing you a predefined config which
works for your special case.

But, if you have further questions, feel free to ask.

Regards,
Edgar

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org